using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Web;

namespace ModWatch
{

	/// <summary>
	/// Provides a base implementation for <see cref="ModWatch.AlertBehaviorBase"/> controls
	/// that define how the user should be notified if changes have occurred.
	/// </summary>
	[PersistChildren(false)]
	[ParseChildren(true)]
	public abstract class AlertBehaviorBase : ModWatchScriptControlBase
	{

		/// <summary>
		/// Returns the client id of the <see cref="AlertBehaviorBase"/>
		/// Component that should be called when the user
		/// should be notified of a change.
		/// </summary>
		/// <returns>
		/// The client id of the <see cref="AlertBehaviorBase"/>
		/// Component associated with the control.
		/// </returns>
		public virtual string GetClientComponentID()
		{
			return this.ClientID;
		}

		/// <summary>
		/// Raises the <see cref="System.Web.UI.Control.Init"/> event.
		/// </summary>
		/// <param name="e">
		/// An <see cref="System.EventArgs"/>
		/// object that contains event data.
		/// </param>
		protected override void OnInit(EventArgs e)
		{
			base.OnInit(e);

			this.GettingScriptReferences += new EventHandler<ScriptReferencesEventArgs>(this_GettingScriptReferences);
		}

		/// <summary>
		/// Registers the scripts needed by the
		/// <see cref="ModWatch.AlertBehaviorBase"/> class.
		/// </summary>
		/// <param name="sender">
		/// The <see cref="System.Object"/> that fired the
		/// <see cref="ModWatch.ModWatchScriptControlBase.GettingScriptReferences"/> event.
		/// </param>
		/// <param name="e">
		/// A <see cref="ModWatch.ScriptReferencesEventArgs"/> object that contains the event data.
		/// </param>
		private void this_GettingScriptReferences(object sender, ScriptReferencesEventArgs e)
		{
			e.AddWebResourceScriptReference("ModWatch.Scripts.AlertBehaviorBase.js");
			e.AddWebResourceScriptReference("ModWatch.Scripts.AlertEventArgs.js");
		}

	}

}
